package com.xiang.consumer;

import com.xiang.config.RabbitMqTopicConfig1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Topics主题模式
 * 另一种写法
 *
 * @author: xiangtianlei
 * @Date: 2022-9-9
 */
@Component
public class ConsumerTopics1 {
    Logger log = LoggerFactory.getLogger(ConsumerTopics1.class);

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(RabbitMqTopicConfig1.QUEUE_TOPICS_EMAIL),
            exchange = @Exchange(name = RabbitMqTopicConfig1.EXCHANGE_TOPICS, type = ExchangeTypes.TOPIC),
            key = RabbitMqTopicConfig1.ROUTINGKEY_EMAIL
    ))
    public void listenerTopicsQueueEmail(String msg) {
        log.info("监听#.email.#队列的消息为：" + msg);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(RabbitMqTopicConfig1.QUEUE_TOPICSM_SMS),
            exchange = @Exchange(name = RabbitMqTopicConfig1.EXCHANGE_TOPICS, type = ExchangeTypes.TOPIC),
            key = RabbitMqTopicConfig1.ROUTINGKEY_SMS
    ))
    public void listenerTopicsQueueSms(String msg) {
        log.info("监听*.sms.#队列的消息为：" + msg);
    }

}
